﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xyz.BusinessObjects;
using Xyz.DataObjects.Interfaces;

namespace Xyz.DataObjects.Entity.Dao
{
    public class EntityFlightPriceDao : IFlightPriceDao
    {
        public decimal GetFlightPriceByFlightIdSeatTypeCode(int flightId, string seatTypeCode)
        {
            using (var context = EntityObjectFactory.CreateContext())
            {
                var flightPrice = context.FlightPriceEntities.SingleOrDefault(x => x.FlightId == flightId && x.SeatTypeCode == seatTypeCode);

                
                if (flightPrice == null)
                {
                    return 0;
                }
                else
                {

                    return Mapper.Map(flightPrice).Price;
                }
            }
        }
    }
}
